<?php include 'app/common/templates/header.php' ?>
<?php include 'pagelets/templates/commonmenu.php' ?>

<script type="text/javascript">
var proxy = new JSONRPCProxy('<?= $this->JSONRPCURL ?>');

function showDetails(id, el) {
	el.style.backgroundColor = "#FFFFA0";
	
	proxy.GetPerson({person_id: id}, 
		function(result) {
			var bd = result.birthDate.split('-');
			var dd = result.deathDate.split('-');
			
			$('details').innerHTML = result.firstName + " " + result.lastName + "<br>" + 
				bd[1] + "/" + bd[2] + "/" + bd[0] + " - " + dd[1] + "/" + dd[2] + "/" + dd[0] + "<br>" +
				result.gender + "<br>";  
		});
}

function clearDetails(el) {
	el.style.backgroundColor = "#FFFFFF";
	$('details').innerHTML = '';
}
</script>
<p>
<table border="0" cellpadding="4">
    <tr><td style="font-weight: bold">ID</td><td style="font-weight: bold">Name</td></tr>

<?php foreach ($this->persons as $person): ?>
	<tr>
		<td><?= $person['id'] ?></td>
		<td><span class="listDetail" onmouseover="showDetails('<?= $person['id'] ?>', this)" onmouseout="clearDetails(this)"><?= $person['firstName'] ?> <?= $person['lastName'] ?></span></td>
		<td><a href="<?= $this->DeleteURL ?>/DeletePerson/<?= $person['id'] ?>">Delete</a></td>
	</tr>
<?php endforeach; ?>
</table>

<div><strong>Details:</strong>
<div id="details"></div>
</div>

<?php include 'app/common/templates/footer.php' ?>

